Skip to content

fix: reject invalid tool call inputs and retry#582

Merged
FL4TLiN3 merged 4 commits intomainfrom
fix/invalid-tool-call-input
Feb 19, 2026
Merged

fix: reject invalid tool call inputs and retry#582
FL4TLiN3 merged 4 commits intomainfrom
fix/invalid-tool-call-input

Conversation

@FL4TLiN3
Copy link
Contributor

Summary

  • Detect AI SDK's invalid flag on tool calls and trigger retry with error context instead of casting malformed input and sending to the Anthropic API
  • Tighten ToolCallPart.args schema from z.unknown() to z.record(z.string(), z.unknown()) for defense-in-depth validation
  • Fixes messages.X.content.Y.tool_use.input: Input should be a valid dictionary API errors

Test plan

  • pnpm typecheck passes (all 23 packages)
  • pnpm test passes (1098 tests)
  • pnpm test:e2e passes (76 tests, 18 files)
  • pnpm run validate:changeset passes

🤖 Generated with Claude Code

FL4TLiN3 and others added 4 commits February 19, 2026 06:13
When the AI SDK fails to parse tool call input (marking it as invalid),
the runtime was previously casting the malformed input as Record and
sending it to the API, causing "Input should be a valid dictionary"
errors from Anthropic.

Now invalid tool calls are detected and trigger a retry with error
context, giving the LLM a chance to regenerate valid tool calls.
Also tightens ToolCallPart.args schema from z.unknown() to z.record()
for defense-in-depth validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@FL4TLiN3 FL4TLiN3 merged commit 1c73db0 into main Feb 19, 2026
11 checks passed
@FL4TLiN3 FL4TLiN3 deleted the fix/invalid-tool-call-input branch February 19, 2026 13:00
@FL4TLiN3 FL4TLiN3 mentioned this pull request Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant